package com.sphd.emanu.activity.comactivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;

import com.sphd.emanu.R;
import com.sphd.emanu.activity.login.LoginActivity;
import com.sphd.emanu.config.Constant;
import com.wzutils.AppUtils;
import com.wzutils.SPUtils;
import com.wzutils.base.BaseActivity;

/**
 * 启动界面 程序的入口
 *
 * @Author Hu
 * @Time 2017/5/10 -- 10:55.
 * @Email 87683202@qq.com
 */
public class StartActivity extends AppCompatActivity {
    Handler handler;
    Runnable runnable;
    Intent intent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_start);
        intent = new Intent();
        intent.putExtra(Constant.CHANGE_PWD, false);
        handler = new Handler();

        runnable = new Runnable() {
            @Override
            public void run() {
                if (SPUtils.contains(getApplicationContext(), Constant.VER_NO)) {
                    //判断本地版本号与存储的版本号是否一致 如果不一致则认定为新更新程序进入引导界面
                    if (AppUtils.getVersionName(getApplicationContext()).equals(SPUtils.get(getApplicationContext(), Constant.VER_NO, ""))) {
                        //正常跳转界面
                        intent.setClass(StartActivity.this, LoginActivity.class);
                        startActivity(intent);
                        finish();
                    } else {
                        //启动引导界面
                        SPUtils.put(getApplicationContext(), Constant.VER_NO, AppUtils.getVersionName(getApplicationContext()));
                        intent.setClass(StartActivity.this, WelComeActivity.class);
                        startActivity(intent);
                        finish();
                    }

                } else {
                    //启动引导界面
                    SPUtils.put(getApplicationContext(), Constant.VER_NO, AppUtils.getVersionName(getApplicationContext()));
                    intent.setClass(StartActivity.this, WelComeActivity.class);
                    startActivity(intent);
                    finish();
                }

            }
        };
        //这的时间长度可自行调整
        handler.postDelayed(runnable, 3500);
    }

}
